<template>
  <div class="inputs">
    <form v-bind:action="searchMsg.myUrl" method="GET" role="search">
      <label for="search">Search for stuff</label>
      <input id="search" :title="searchMsg.message" type="search" v-bind:name="searchMsg.uname" :placeholder="searchMsg.message" autofocus
             required/>
      <button type="submit" onclick="document.postform.submit();">Go</button>
    </form>
  </div>
</template>

<script>
export default {
  name: 'search-input',
  props: ['msg'],
  data () {
    return {
      searchMsg: this.$props.msg
    }
  }
}
</script>

<style scoped>
div {
  --rad: .7rem;
  --dur: .3s;
  --color-dark: #2f2f2f;
  --color-light: #fff;
  --color-brand: #57bd84;
  --font-fam: 'Lato', sans-serif;
  --height: 3rem;
  --btn-width: 6rem;
  --bez: cubic-bezier(0, 0, 0.43, 1.49);
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 3rem;
  font-size: 0.6em;
}

*, *::before, *::after {
  box-sizing: inherit;
}

form {
  position: relative;
  width: 30rem;
  background: var(--color-brand);
  border-radius: var(--rad);
  text-align: left;
}

input, button {
  height: var(--height);
  font-family: var(--font-fam);
  border: 0;
  color: var(--color-dark);
  font-size: 1.8rem;
}

input[type="search"] {
  outline: 0;
  width: 100%;
  background: var(--color-light);
  padding: 0 1.6rem;
  border-radius: var(--rad);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  transition: all var(--dur) var(--bez);
  transition-property: width, border-radius;
  z-index: 1;
  position: relative;
}

button {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  width: var(--btn-width);
  font-weight: bold;
  background: var(--color-brand);
  border-radius: 0 var(--rad) var(--rad) 0;
}

input:not(:placeholder-shown) {
  border-radius: var(--rad) 0 0 var(--rad);
  width: calc(100% - var(--btn-width));
}

input:not(:placeholder-shown) + button {
  display: block;
}

label {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
}
@media screen and (max-width: 900px){
  div {
    --rad: .7rem;
    --dur: .3s;
    --color-dark: #2f2f2f;
    --color-light: #fff;
    --color-brand: #57bd84;
    --font-fam: 'Lato', sans-serif;
    --height: 3rem;
    --btn-width: 6rem;
    --bez: cubic-bezier(0, 0, 0.43, 1.49);
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 3rem;
    font-size: 0.3em;
    text-align: center;
  }

  *, *::before, *::after {
    box-sizing: inherit;
  }

  form {
    position: relative;
    margin: 0 auto;
    width: 25rem;
    background: var(--color-brand);
    border-radius: var(--rad);
    text-align: left;
  }

  input, button {
    height: var(--height);
    font-family: var(--font-fam);
    border: 0;
    color: var(--color-dark);
    font-size: 1.8rem;
  }

  input[type="search"] {
    outline: 0;
    width: 100%;
    background: var(--color-light);
    padding: 0 1.6rem;
    border-radius: var(--rad);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all var(--dur) var(--bez);
    transition-property: width, border-radius;
    z-index: 1;
    position: relative;
  }

  button {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    width: var(--btn-width);
    font-weight: bold;
    background: var(--color-brand);
    border-radius: 0 var(--rad) var(--rad) 0;
  }

  input:not(:placeholder-shown) {
    border-radius: var(--rad) 0 0 var(--rad);
    width: calc(100% - var(--btn-width));
  }

  input:not(:placeholder-shown) + button {
    display: block;
  }

  label {
    position: absolute;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0;
    border: 0;
    height: 1px;
    width: 1px;
    overflow: hidden;
  }
}
</style>
